﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Resources;
using System.IO;
using System.Windows;
using System.Windows.Resources;


namespace FBNotifier
{
    class WinMMWrapper
    {
        public const UInt32 SND_ASYNC = 1;
        public const UInt32 SND_MEMORY = 4;

        [DllImport("Winmm.dll")]
        public static extern bool PlaySound(byte[] data, IntPtr hMod, UInt32 dwFlags);

        public WinMMWrapper()
        {
        }

        public static void PlayWavResource(string path)
        {
            // Navigate to xaml page
            StreamResourceInfo info = Application.GetResourceStream(new Uri(path));

            // bring stream into a byte array
            byte[] bStr = new Byte[info.Stream.Length];
            info.Stream.Read(bStr, 0, (int)info.Stream.Length);

            // play the resource
            PlaySound(bStr, IntPtr.Zero, SND_ASYNC | SND_MEMORY);
        }
    }
}
